<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>资源管理</title>
<%@include file="/jsp/common/inc.jsp"%>
<script type="text/javascript">
	$(function() {
		$("#treeGrid").treegrid({
			url : '${pageContext.request.contextPath}/resourceController/treeGrid',
			idField : 'id',
			treeField : 'name',
			parentField : 'pid',
			fit : true,
			fitColumns : false,
			border : false,
			rownumbers : true,
			columns : [ [ {
				field : 'id',
				title : '编号',
				width : 60,
				align : 'center'
			}, {
				field : 'name',
				title : '菜单名称',
				width : 150,
			}, {
				field : 'url',
				title : '地址',
				width : 200,
				sortable : true,

			}, {
				field : 'remark',
				title : '备注',
				width : 100,
				align : 'center'
			}, {
				field : 'iconCls',
				title : '图标',
				width : 50,
				sortable : true,
				align : 'center'
			}, {
				field : 'seq',
				title : '排序',
				width : 50,
				align : 'center'
			}, {
				field : 'pid',
				title : '上级资源',
				width : 100,
				align : 'center'
			}, {
				field : 'typeName',
				title : '资源类型',
				width : 100,
				align : 'center'
			}, {
				field : 'action',
				title : '操作',
				width : 100,
				alige : 'center',
				formatter : ''

			} ] ],
			onLoadSuccess : function() {
				$('#treeGrid').treegrid('collapseAll')//折叠所有节点
			},
			toolbar : '#toolbar',
			onContextMenu : function(e, row) {
				e.preventDefault();
				$(this).treegrid('unselectAll');
				$(this).treegrid('select', row.id);
				$('#menu').menu('show', {
					left : e.pageX,
					top : e.pageY
				});
			},
		});
	});

	//展开所有节点
	function redo() {
		$('#treeGrid').treegrid('expandAll');
	}

	//折叠所有节点
	function undo() {
		$('#treeGrid').treegrid('collapseAll');
	}

	//添加资源
	function addResource(data) {
		$("#ResourceWindow").window("open");
		$('#resource_add').form('clear');
		$('#typeId').combobox('setValue', '0');
	}
</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',border:false" title="">
		<table id="treeGrid"></table>
	</div>
	
	<div id="toolbar" style="display: none;">
		<a onclick="addResource();" href="javascript:void(0);"
			class="easyui-linkbutton"
			data-options="plain:true,iconCls:'pencil_add'">添加</a> <a
			onclick="redo();" href="javascript:void(0);"
			class="easyui-linkbutton"
			data-options="plain:true,iconCls:'resultset_next'">展开</a> <a
			onclick="undo();" href="javascript:void(0);"
			class="easyui-linkbutton"
			data-options="plain:true,iconCls:'resultset_previous'">折叠</a>
	</div>

	<div id="menu" class="easyui-menu" style="width: 120px; display: none;">
		<div onclick="addResource();" data-options="iconCls:'pencil_add'">增加</div>
	</div>
	<jsp:include page="../admin/resource_add.jsp"></jsp:include>
</body>
</html>